function getPromiseData(val) {
  return new Promise((resolve) => {
    resolve(val);
  });
}

function* getData(val) {
  let ret1 = yield getPromiseData(val);
  let ret2 = yield getPromiseData(ret1 + "111");
  let ret3 = yield getPromiseData(ret2 + "222");
  let ret4 = yield getPromiseData(ret3 + "333");
  console.log(ret4);
}

function execGenerator(getFn, val) {
  const generator = getFn(val);
  function exec(res) {
    const result = generator.next(res);
    if (result.done) {
      return result.val;
    }
    result.value.then((res) => {
      exec(res);
    });
  }
  exec(val);
}

execGenerator(getData, "000");
